-module(file2).
-compile(export_all).

default() -> io:fwrite("file2 default...\n"),
             io:fwrite("Woop woop.\n").

do_connect() ->
   SlaveProc = "slave@" ++ net_adm:localhost(),
   net_adm:ping(list_to_atom(SlaveProc)),
   Slave = lists:nth(1,nodes()),
   io:format("~w",[Slave]),
   FileToSend = "file2.beam",
   {listener,Slave} ! do_run,
   {listener,Slave} ! {new_fun,
                       fun file2:default/0,
                       read_file(FileToSend),
                       FileToSend
                      },
   {listener,Slave} ! do_run.

read_file(FileName) ->
   case file:read_file(FileName) of
      {ok,Binary} ->
         Binary;
      {error,reason} ->
         io:fwrite("Error sending binary to test.."++reason)
   end.
